import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

/**
 * 固定路由
 * 没有权限要求的基础页面
 */
export const constantRoutes = [{
		path: '/',
		redirect: '/index/index-lst',
	},
	// 404 这个页面丢失了...
	{
		path: '/404',
		component: () =>
			import('@/views/error-page/404'),
		hidden: true
	},
	// 401 没有权限
	{
		path: '/401',
		component: () =>
			import('@/views/error-page/401'),
		hidden: true
	},

  // 登录页面
  {
  	path: '/login',
  	component: () =>
  		import('@/views/login/index'),
  	hidden: true
  },
  // 忘记密码
  {
  	path: '/forget',
  	component: () =>
  		import('@/views/login/forget'),
  	hidden: true
  }
]

const createRouter = () => new Router({
	// mode: 'history', // 需要服务支持  history去掉路由地址的#
	scrollBehavior: () => ({
		y: 0
	}),
	routes: constantRoutes
})

const router = createRouter()
export function resetRouter() {
	const newRouter = createRouter()
	router.matcher = newRouter.matcher // 重置路由
}

export default router
